#ifndef _DATA_BLOCK_H_
#define _DATA_BLOCK_H_

namespace share
{

class DataBlock
{
public:
	enum
	{
		K = 1024,
		M = 1024*1024
	};
public:
	DataBlock( unsigned size = 4*K, Allocator *allocator = 0 );


	~DataBlock( void );

	char* rd_ptr( ) const;
	char* wr_ptr( ) const;

	void rd_ptr( size_t n );
	void wr_ptr( size_t n );

	size_t length( ) const;
	size_t size( ) const;
	size_t space( ) const ;

	int crunch( );
	int resize( size_t size );

	int copy( const char* buf, size_t len );
private:

	Allocator *allocator_;

	char *base_;
	char *rd_ptr_;
	char *wr_ptr_;
	size_t size_;

private:
	DataBlock& operator = ( const DataBlock &data );
	DataBlock( const DataBlock &data );

};

}
#endif